﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RM.WinClient.RMServices;
//using RM.WinClient.RMQuestionService;
using System.Timers;
using System.IO;
using System.Diagnostics;
using Microsoft.Windows.Controls;
using System.Windows.Threading;
using RM.WinClient.Utilities;

namespace RM.WinClient
{
    public partial class MasterPage : Window
    {
        #region Declaration
        Timer currenttime = new Timer(1000);
        #endregion

        public MasterPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MasterPage_Loaded);
            InitializeTray();
        }

        void MasterPage_Loaded(object sender, RoutedEventArgs e)
        {
            currenttime.Elapsed += new ElapsedEventHandler(currenttime_Elapsed);
            currenttime.Start();
            TestTimer.OnStart += new TestTimer.StartTest(TestTimer_OnStart);
        }

        void TestTimer_OnStart()
        {
            mnuStop.Visible = true;
        }

        
        #region Stop Test

        //protected override void mnuStop_Click(object sender, EventArgs e)
        //{
        //    if (MessageBoxResult.Yes == MessageBox.Show("Are you sure you want to stop the test?", "Stop", MessageBoxButton.YesNo))
        //    {
        //        new Finish(runningTime, selectedcandidateId).ShowDialog();
        //    }
        //}

        #endregion

        #region Show Current Time

        void currenttime_Elapsed(object sender, ElapsedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, (EventHandler)
              delegate
              {
                  GetCurrentTime();
              }, null, null);

            //GetCurrentTime();
        }

        #endregion

        private void GetCurrentTime()
        {
            String sCurrTime = System.DateTime.Now.ToLongTimeString();
            lblCurrentTime.Content = sCurrTime;
        }

        private void ChangeLogoutColor(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Logout.Foreground = new SolidColorBrush(Color.FromArgb(255, 9, 38, 224));
        }

        private void RevertLogoutColor(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Logout.Foreground = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50));
        }

       
        public void StartTest()
        {
            mnuStop.Visible = true;
            //selectedcandidateId = (int)(((Button)sender).Tag);
            this.Close();
            
        }

        public void Navigate(string URI)
        {
            NavigationFrame.Navigate(new Uri(URI, UriKind.Relative));
        }
    }
}
